home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1995-12-01 | 8.9 KB | 202 lines | [ TEXT/CWIE]
Subject: Writing MDEF->scratching head! From: starlabs@aol.com (StarLabs) Date: 30 Nov 1995 04:30:50 -0500 Message-ID: <49jtka$df8@newsbf02.news.aol.com> I'm writing a custom MDEF which mainly draws text, not graphics. So it has to support submenus. Consequently I'm having problems with submenus and popup menus. The submenu problem is my greatest concern: Whenever the mouse is moved over a menu item in my MDEF menu the submenu is positioned according to the *mouse location*. This is NOT how the system MDEF handles this (the submenu is positioned correctly next to the menu item regardless of the mouse location). So if the mouse is near the bottom of the menu item the submenu is placed lower; if the mouse is near the top of the menu item the submenu is placed higher. For the system MDEF, the submenu's location is always constant, the submenu's top flushed with the top of the menu item. Any ideas on what I'm missing? However, this is not the biggest problem. The biggest problem: After the submenu is shown it's sent a total of 5 mDrawMsg calls! I added a SysBeep() to the routine which handles mDrawMsg so I know the submenu is getting redundant mDrawMsg calls. This results in the menu being erased and redrawn, causing flicker. So why is my MDEF getting these redundant mDrawMsg messages? I checked the older Concordia MDEF (on the bookmark CD) and it seems to be having this problem too. My MDEF uses as its basis the MDEF sample taken from THINK Reference - admittedly old but looking at it I can't see anything wrong. My best guess is the problem is confined not to my mDrawMsg handler but rather my mChooseMsg handler, below (gutted and simplified, but still works and still has problems!): void DoChooseMsg( MenuHandle whichMenu, Rect *menuRect, Point hitPt, short *itemID) { short mouseItem; short oldItem = *itemID; mouseItem = FindMenuItem(whichMenu, menuRect, hitPt); if (mouseItem==0) { DrawMenuItem(whichMenu, menuRect, oldItem, kMenuUnhilited); *itemID=0; } else if ( mouseItem != *itemID ) { DrawMenuItem(whichMenu, menuRect, oldItem, kMenuUnhilited); DrawMenuItem(whichMenu, menuRect, mouseItem, kMenuHilited); *itemID = mouseItem; } } // END DoChooseMsg Or is there some quirks in the Menu Manager that I have to know to make the MDEF work correctly? I am seriously puzzled about this one... (And I haven't even mentioned the pop-up menu problem!) One bug at a time. :-o Thanks in advance for any pointers, --Hiep ---------- Subj: Re: Writing MDEF->scratching head! Date: Thu, Nov 30, 1995 9:55 AM PST From: jordanz@altura.com X-From: jordanz@altura.com (Jordan Zimmerman) To: starlabs@aol.com (StarLabs) (A copy of this message has also been posted to the following newsgroups: comp.sys.mac.programmer.help) > The biggest problem: After the submenu is shown it's sent a total of 5 > mDrawMsg calls! I added a SysBeep() to the routine which handles mDrawMsg > so I know the submenu is getting redundant mDrawMsg calls. This results in > the menu being erased and redrawn, causing flicker. So why is my MDEF > getting these redundant mDrawMsg messages? This is because you are not setting the mbItemRect in the mbSaveLoc. You don't know what these are, you say? Well maybe that's because they've never been documented ... anywhere! Anyway, if you closely read the System 6 System MDEF provided on the Apple Developer CDs, you'll see that it sets this funky low-level global mbItemRect. The only #defines I've seen for it are in the MPW assembly interfaces in a file called privates.a. Once you properly set, the problems you've mentioned magically go away. Go figure... -- Jordan Zimmerman, Altura Software home page: http://www.altura.com/jordanz Spock's Beard: http://www.altura.com/spocks_beard ----------------------- Headers -------------------------------- From jordanz@altura.com Thu Nov 30 12:55:20 1995 Return-Path: jordanz@altura.com Received: from scruz.net (nic.scruz.net [165.227.1.2]) by emin06.mail.aol.com (8.6.12/8.6.12) with ESMTP id MAA10744 for <starlabs@aol.com>; Thu, 30 Nov 1995 12:55:04 -0500 Received: from 204.147.232.52 by scruz.net (8.6.9/1.34) id JAA13505; Thu, 30 Nov 1995 09:23:44 -0800 Message-Id: <199511301723.JAA13505@scruz.net> Date: Thu, 30 Nov 1995 09:23:27 -0900 From: jordanz@altura.com (Jordan Zimmerman) To: starlabs@aol.com (StarLabs) Subject: Re: Writing MDEF->scratching head! Newsgroups: comp.sys.mac.programmer.help References: <49jtka$df8@newsbf02.news.aol.com> Organization: Altura Software, Inc. --------- Subject: Re: Writing MDEF->scratching head! From: starlabs@aol.com (StarLabs) Date: 1 Dec 1995 04:19:32 -0500 Message-ID: <49mhb4$gjr@newsbf02.news.aol.com> >> This is because you are not setting the mbItemRect in the mbSaveLoc. You don't know what these are, you say? Well maybe that's because they've never been documented ... anywhere! >> Thanks - I had a sneaking suspicion something like this was the reason, but I couldn't believe Apple would withold info from programmers that would prevent them from writing WORKING code! I should have known better... Anyway, after careful reading of some sample MDEFs I had done as you had suggested and voila! No more submenu flashing when the mouse was over a menu item which pointed to a submenu. However, I'm still having problems with the submenu still being placed erratically: The submenu itself seems to alternate between being located high or low in relation to the menu item which points to it, probably also being partly determined by the mouse's location, NOT the menu item's rect. Aargh! Unlike the system MDEF, where the submenu is placed flushed top with the menu item, regardless of the mouse's location. I tried fiddling with mbUglyScroll. I also implemented fiddling with the MenuDisable low-mem global. But to no avail. Any suggestions? Do I have to look in mChooseMsg or mPopupMsg for this problem? Thanks, --Hiep // --------------------------------------------------------------------------- Taken from Private.a... ; equates for dynamic menuList structure ; ;----- Part 1 -- regular menus mbResID EQU 4 ; menuBar variant offset in menuList [word] menu1Size EQU mbResID + 2 ; Must be = 6 forever!!! ;----- Part 2 -- hierarchical menus lastHMenu EQU 0 ; offset in HMenu part of dynamic menuList [word] menuTitleSave EQU lastHMenu + 2 ; handle to saved bits behind title rectangle [handle] menu2Size EQU menuTitleSave+4 ; size of HMenu entry menuHoH EQU 0 ; hierarchical menu [handle] ;----- Size of menuList at InitMenus time -- no menus, no hierarchical menus initMListSize EQU menu1Size + menu2Size ; equates for mbarproc's save structure created when it receives Init Msg (Msg #3) ; ;----- Header lastMBSave EQU 0 ; offset to last menu saved in structure [word] mbCustomStorage EQU lastMBSave + 2 ; private storage for custom mbarproc's [handle] mbItemRect EQU mbCustomStorage + 4 ; rect of currently chosen menu item [rect] mbMenuDelay EQU mbItemRect + 8 ; get MenuDelay from paramram and store here [byte] mbMenuDrag EQU mbMenuDelay + 1 ; get MenuDrag from paramram and store here [byte] mbUglyScroll EQU mbMenuDrag + 1 ; flag to tell whether HMenu has been brought [word] ; before scrolling happens mbIconState EQU mbUglyScroll + 2 ; Place to save NMgr icon state mbHeader EQU mbIconState + 2 ; size of mb save header [$14] ; !!!!! CAUTION: mbHeader MUST be smaller than mbEntrySize !!!!! ;----- Entry mbRectSave EQU 0 ; rectangle of menu on screen [8 bytes] mbBitsSave EQU mbRectSave + 8 ; handle to saved bits behind menu rectangle mbMenuDir EQU mbBitsSave + 4 ; direction menu was placed on screen, ; to right or left of title (if first menu) ; or previous menu (if hierarchical menu) mbMLOffset EQU mbMenuDir + 2 ; 6 byte offset of menu in menuList [word] mbMLHandle EQU mbMLOffset + 2 ; handle of menu in menuList mbTopScroll EQU mbMLHandle + 4 ; top scrolled to menu item, from global topMenuItem [word] mbBotScroll EQU mbTopScroll + 2 ; bottom scrolled to menu item, from global atMenuBottom [word] mbReserved EQU mbBotScroll + 2 ; reserved field [long] mbEntrySize EQU mbReserved + 4 mbSaveSize EQU mbEntrySize*6 ; x-byte header and 5 entries of x-bytes each firstAltMenuCmd EQU $1B altMenuCmd1 EQU $1D ; itemCmd == $1D ==> unused indicator reserved for future Apple use altMenuCmd2 EQU $1E ; itemCmd == $1E ==> unused indicator reserved for future Apple use altMenuCmd3 EQU $1F ; itemCmd == $1F ==> unused indicator reserved for future Apple use lastAltMenuCmd EQU $1F mbRightDir EQU 0 ; menu went to the right (direction) mbLeftDir EQU 1 ; menu went to the left (direction) menuDelay EQU $7E ; param ram locations for user settable menuDrag EQU $7F ; hierarchical menu delay and drag ticks